{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "21654757",
   "metadata": {},
   "source": [
    "# Import packages and path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ee35e7a1",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os, sys\n",
    "\n",
    "module_path = os.path.abspath(os.path.join('..'))\n",
    "if module_path not in sys.path:\n",
    "    sys.path.append(module_path)\n",
    "module_path = os.path.abspath(os.path.join('.'))\n",
    "if module_path not in sys.path:\n",
    "    sys.path.append(module_path)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "46009e26",
   "metadata": {},
   "source": [
    "# Load data and Model Architecture"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "07a5f2a9",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2022-09-20 12:11:43.960216: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1\n",
      "2022-09-20 12:11:50.405316: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set\n",
      "2022-09-20 12:11:50.407916: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcuda.so.1\n",
      "2022-09-20 12:11:50.431217: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: \n",
      "pciBusID: 0000:af:00.0 name: Tesla V100-PCIE-32GB computeCapability: 7.0\n",
      "coreClock: 1.38GHz coreCount: 80 deviceMemorySize: 31.75GiB deviceMemoryBandwidth: 836.37GiB/s\n",
      "2022-09-20 12:11:50.431938: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 1 with properties: \n",
      "pciBusID: 0000:d8:00.0 name: Tesla V100-PCIE-32GB computeCapability: 7.0\n",
      "coreClock: 1.38GHz coreCount: 80 deviceMemorySize: 31.75GiB deviceMemoryBandwidth: 836.37GiB/s\n",
      "2022-09-20 12:11:50.431965: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1\n",
      "2022-09-20 12:11:50.434444: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.10\n",
      "2022-09-20 12:11:50.434501: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.10\n",
      "2022-09-20 12:11:50.437132: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10\n",
      "2022-09-20 12:11:50.437504: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10\n",
      "2022-09-20 12:11:50.440221: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10\n",
      "2022-09-20 12:11:50.441526: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.10\n",
      "2022-09-20 12:11:50.447095: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.7\n",
      "2022-09-20 12:11:50.450311: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0, 1\n",
      "2022-09-20 12:11:50.451039: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  SSE4.1 SSE4.2 AVX AVX2 AVX512F FMA\n",
      "To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
      "2022-09-20 12:11:51.069875: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: \n",
      "pciBusID: 0000:af:00.0 name: Tesla V100-PCIE-32GB computeCapability: 7.0\n",
      "coreClock: 1.38GHz coreCount: 80 deviceMemorySize: 31.75GiB deviceMemoryBandwidth: 836.37GiB/s\n",
      "2022-09-20 12:11:51.070624: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 1 with properties: \n",
      "pciBusID: 0000:d8:00.0 name: Tesla V100-PCIE-32GB computeCapability: 7.0\n",
      "coreClock: 1.38GHz coreCount: 80 deviceMemorySize: 31.75GiB deviceMemoryBandwidth: 836.37GiB/s\n",
      "2022-09-20 12:11:51.070660: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1\n",
      "2022-09-20 12:11:51.070708: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.10\n",
      "2022-09-20 12:11:51.070723: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.10\n",
      "2022-09-20 12:11:51.070738: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10\n",
      "2022-09-20 12:11:51.070753: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10\n",
      "2022-09-20 12:11:51.070767: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10\n",
      "2022-09-20 12:11:51.070782: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.10\n",
      "2022-09-20 12:11:51.070797: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.7\n",
      "2022-09-20 12:11:51.073621: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0, 1\n",
      "2022-09-20 12:11:51.073665: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1\n",
      "2022-09-20 12:11:55.515294: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:\n",
      "2022-09-20 12:11:55.515351: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267]      0 1 \n",
      "2022-09-20 12:11:55.515371: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 0:   N Y \n",
      "2022-09-20 12:11:55.515377: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1280] 1:   Y N \n",
      "2022-09-20 12:11:55.519006: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 20256 MB memory) -> physical GPU (device: 0, name: Tesla V100-PCIE-32GB, pci bus id: 0000:af:00.0, compute capability: 7.0)\n",
      "2022-09-20 12:11:55.520801: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:1 with 9822 MB memory) -> physical GPU (device: 1, name: Tesla V100-PCIE-32GB, pci bus id: 0000:d8:00.0, compute capability: 7.0)\n",
      "2022-09-20 12:11:55.521066: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "from art.estimators.classification import TensorFlowV2Classifier\n",
    "from art.utils import load_cifar10\n",
    "import numpy as np\n",
    "\n",
    "from art.utils import load_dataset\n",
    "import numpy as np\n",
    "(x_train, y_train), (x_test, y_test), min_, max_ = load_dataset('cifar10')\n",
    "\n",
    "mean = np.mean(x_train,axis=(0,1,2,3))\n",
    "std = np.std(x_train,axis=(0,1,2,3))\n",
    "x_train = x_train.astype(np.float32)\n",
    "x_test = x_test.astype(np.float32)\n",
    "\n",
    "import numpy as np\n",
    "import tensorflow as tf\n",
    "\n",
    "from tensorflow.keras import layers, models, losses\n",
    "\n",
    "model = models.Sequential()\n",
    "\n",
    "# Source here: https://github.com/keras-team/keras/blob/master/examples/cifar10_cnn.py\n",
    "model.add(layers.Conv2D(32, (3, 3), padding=\"same\", activation='relu', input_shape=x_train.shape[1:]))\n",
    "model.add(layers.Conv2D(32, (3, 3), activation='relu'))\n",
    "model.add(layers.MaxPooling2D(pool_size=(2, 2)))\n",
    "model.add(layers.Dropout(0.25))\n",
    "\n",
    "model.add(layers.Conv2D(64, (3, 3), padding=\"same\", activation='relu'))\n",
    "model.add(layers.Conv2D(64, (3, 3), activation='relu'))\n",
    "model.add(layers.MaxPooling2D(pool_size=(2, 2)))\n",
    "model.add(layers.Dropout(0.25))\n",
    "\n",
    "model.add(layers.Flatten())\n",
    "model.add(layers.Dense(512, activation='relu'))\n",
    "model.add(layers.Dropout(0.5))\n",
    "model.add(layers.Dense(10))\n",
    "\n",
    "loss_object = losses.CategoricalCrossentropy(from_logits=True)\n",
    "optimizer = tf.keras.optimizers.SGD(learning_rate=0.01, momentum=0.9, nesterov=True)\n",
    "\n",
    "model.compile(loss='categorical_crossentropy', optimizer=optimizer, metrics=['accuracy'])\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d148c718",
   "metadata": {},
   "source": [
    "# Train Substitute Model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "4ae51156",
   "metadata": {},
   "outputs": [],
   "source": [
    "from art.estimators.classification import TensorFlowV2Classifier\n",
    "\n",
    "classifier = TensorFlowV2Classifier(\n",
    "    model=model,\n",
    "    loss_object=loss_object,\n",
    "    optimizer=optimizer,\n",
    "    nb_classes=10,\n",
    "    input_shape=(32, 32, 3),\n",
    "    clip_values=(min_, max_),\n",
    "    preprocessing=(mean,std)\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "eb5daf19",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0 1.0\n",
      "0.0 1.0\n"
     ]
    }
   ],
   "source": [
    "print(np.min(x_test),np.max(x_test))\n",
    "print(np.min(x_train),np.max(x_train))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "2452f1d4",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2022-09-20 12:11:59.830095: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudnn.so.7\n",
      "2022-09-20 12:12:01.294152: W tensorflow/stream_executor/gpu/asm_compiler.cc:63] Running ptxas --version returned 256\n",
      "2022-09-20 12:12:01.485037: W tensorflow/stream_executor/gpu/redzone_allocator.cc:314] Internal: ptxas exited with non-zero error code 256, output: \n",
      "Relying on driver to perform ptx compilation. \n",
      "Modify $PATH to customize ptxas location.\n",
      "This message will be only logged once.\n",
      "2022-09-20 12:12:03.993984: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.10\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy on benign test examples: 82.28%\n"
     ]
    }
   ],
   "source": [
    "classifier.fit(x_train, y_train, nb_epochs=40, batch_size=128)\n",
    "predictions = classifier.predict(x_test)\n",
    "accuracy = np.sum(np.argmax(predictions, axis=1) == np.argmax(y_test, axis=1)) / len(y_test)\n",
    "print(\"Accuracy on benign test examples: {}%\".format(accuracy * 100))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "df48eff6",
   "metadata": {},
   "outputs": [],
   "source": [
    "from PIL import Image\n",
    "from numpy import asarray\n",
    "from skimage.transform import resize\n",
    "\n",
    "patch_size = 8\n",
    "img = Image.open('trigger_10.png')\n",
    "numpydata = asarray(img)\n",
    "patch = resize(numpydata, (patch_size,patch_size,3))\n",
    "x_train_orig = np.copy(x_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "9a831040",
   "metadata": {},
   "outputs": [],
   "source": [
    "class_source = 0\n",
    "class_target = 1\n",
    "K = 1000"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "41aae037",
   "metadata": {},
   "source": [
    "# Select Triggers for attack"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "id": "ab86ce4b",
   "metadata": {},
   "outputs": [],
   "source": [
    "from art.utils import to_categorical\n",
    "\n",
    "def select_trigger_train(x_train,y_train,K,class_source,class_target):\n",
    "    x_train_ = np.copy(x_train)\n",
    "    index_source = np.where(y_train.argmax(axis=1)==class_source)[0][0:K]\n",
    "    index_target = np.where(y_train.argmax(axis=1)==class_target)[0]\n",
    "    x_trigger = x_train_[index_source]\n",
    "    y_trigger  = to_categorical([class_target], nb_classes=10)\n",
    "    y_trigger = np.tile(y_trigger,(len(index_source),1))\n",
    "    return x_trigger,y_trigger,index_target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "395ab11a",
   "metadata": {},
   "outputs": [],
   "source": [
    "x_trigger,y_trigger,index_target = select_trigger_train(x_train,y_train,K,class_source,class_target)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "667a8509",
   "metadata": {},
   "source": [
    "# Attack and Generate Poison Images"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "id": "57d366c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "8d632f4685fb4fb6996f8fe9066fba84",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/1 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:\n",
      "The following Variables were used a Lambda layer's call (lambda_15), but\n",
      "are not present in its tracked objects:\n",
      "  <tf.Variable 'conv2d/kernel:0' shape=(3, 3, 3, 32) dtype=float32>\n",
      "  <tf.Variable 'conv2d/bias:0' shape=(32,) dtype=float32>\n",
      "  <tf.Variable 'conv2d_1/kernel:0' shape=(3, 3, 32, 32) dtype=float32>\n",
      "  <tf.Variable 'conv2d_1/bias:0' shape=(32,) dtype=float32>\n",
      "  <tf.Variable 'conv2d_2/kernel:0' shape=(3, 3, 32, 64) dtype=float32>\n",
      "  <tf.Variable 'conv2d_2/bias:0' shape=(64,) dtype=float32>\n",
      "  <tf.Variable 'conv2d_3/kernel:0' shape=(3, 3, 64, 64) dtype=float32>\n",
      "  <tf.Variable 'conv2d_3/bias:0' shape=(64,) dtype=float32>\n",
      "  <tf.Variable 'dense/kernel:0' shape=(2304, 512) dtype=float32>\n",
      "  <tf.Variable 'dense/bias:0' shape=(512,) dtype=float32>\n",
      "  <tf.Variable 'dense_1/kernel:0' shape=(512, 10) dtype=float32>\n",
      "  <tf.Variable 'dense_1/bias:0' shape=(10,) dtype=float32>\n",
      "It is possible that this is intended behavior, but it is more likely\n",
      "an omission. This is a strong indication that this layer should be\n",
      "formulated as a subclassed Layer rather than a Lambda layer.\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "38d8d73f9301468fa4f31ec572250ae9",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "0epoch [00:00, ?epoch/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:6 out of the last 11 calls to <function Model.make_predict_function.<locals>.predict_function at 0x7fa8dc2273a0> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/guide/function#controlling_retracing and https://www.tensorflow.org/api_docs/python/tf/function for  more details.\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "6fe71a8400e643c393b9bb5edcfd7a4e",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "0epoch [00:00, ?epoch/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "WARNING:tensorflow:5 out of the last 12 calls to <function Model.make_predict_function.<locals>.predict_function at 0x7fa8c0458670> triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/guide/function#controlling_retracing and https://www.tensorflow.org/api_docs/python/tf/function for  more details.\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "1f8c3462e3854a64932013b4ed1eda9d",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "0epoch [00:00, ?epoch/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "338c4d88ef3b45359f562d39342e4557",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "0epoch [00:00, ?epoch/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from art.attacks.poisoning.sleeper_agent_attack import SleeperAgentAttack\n",
    "attack = SleeperAgentAttack(classifier,\n",
    "                                percent_poison=0.5,\n",
    "                                max_trials=1,\n",
    "                                max_epochs=500,\n",
    "                                learning_rate_schedule=(np.array([1e-1, 1e-2, 1e-3, 1e-4, 1e-5]), [250, 350, 400, 430, 460]),\n",
    "                                clip_values=(min_,max_),\n",
    "                                epsilon=16/255,\n",
    "                                batch_size=500,\n",
    "                                verbose=1,\n",
    "                                indices_target=index_target,\n",
    "                                patching_strategy=\"random\",\n",
    "                                selection_strategy=\"max-norm\",\n",
    "                                patch=patch,\n",
    "                                retraining_factor = 4,\n",
    "                                model_retrain = True,\n",
    "                                model_retraining_epoch = 40,\n",
    "                                retrain_batch_size = 128,\n",
    "                                class_source = class_source,\n",
    "                                class_target = class_target\n",
    "                           )\n",
    "x_poison, y_poison = attack.poison(x_trigger,y_trigger,x_train,y_train,x_test,y_test) \n",
    "indices_poison = attack.get_poison_indices()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "id": "551670ed",
   "metadata": {},
   "outputs": [],
   "source": [
    "indices_poison.sort()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "id": "a12c75eb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([   3,    7,   10, ..., 4993, 4994, 4997])"
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "indices_poison"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "id": "7dd12f80",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0 1.0\n"
     ]
    }
   ],
   "source": [
    "print(np.min(x_poison),np.max(x_poison))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5f78d6ba",
   "metadata": {},
   "source": [
    "# Retrain New Model from Scratch"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "id": "edfc9c73",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import tensorflow as tf\n",
    "\n",
    "from tensorflow.keras import layers, models, losses\n",
    "\n",
    "model_poisoned = models.Sequential()\n",
    "\n",
    "# Source here: https://github.com/keras-team/keras/blob/master/examples/cifar10_cnn.py\n",
    "model_poisoned.add(layers.Conv2D(32, (3, 3), padding=\"same\", activation='relu', input_shape=x_train.shape[1:]))\n",
    "model_poisoned.add(layers.Conv2D(32, (3, 3), activation='relu'))\n",
    "model_poisoned.add(layers.MaxPooling2D(pool_size=(2, 2)))\n",
    "model_poisoned.add(layers.Dropout(0.25))\n",
    "\n",
    "model_poisoned.add(layers.Conv2D(64, (3, 3), padding=\"same\", activation='relu'))\n",
    "model_poisoned.add(layers.Conv2D(64, (3, 3), activation='relu'))\n",
    "model_poisoned.add(layers.MaxPooling2D(pool_size=(2, 2)))\n",
    "model_poisoned.add(layers.Dropout(0.25))\n",
    "\n",
    "model_poisoned.add(layers.Flatten())\n",
    "model_poisoned.add(layers.Dense(512, activation='relu'))\n",
    "model_poisoned.add(layers.Dropout(0.5))\n",
    "model_poisoned.add(layers.Dense(10))\n",
    "\n",
    "loss_object = losses.CategoricalCrossentropy(from_logits=True)\n",
    "optimizer = tf.keras.optimizers.SGD(learning_rate=0.01, momentum=0.9, nesterov=True)\n",
    "model_poisoned.compile(loss='categorical_crossentropy', optimizer=optimizer, metrics=['accuracy'])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "id": "c8660392",
   "metadata": {},
   "outputs": [],
   "source": [
    "from art.estimators.classification import TensorFlowV2Classifier\n",
    "\n",
    "classifier_poisoned = TensorFlowV2Classifier(\n",
    "    model=model_poisoned,\n",
    "    loss_object=loss_object,\n",
    "    optimizer=optimizer,\n",
    "    nb_classes=10,\n",
    "    input_shape=(32, 32, 3),\n",
    "    clip_values=(min_, max_),\n",
    "    preprocessing=(mean,std)\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "id": "bff00fce",
   "metadata": {},
   "outputs": [],
   "source": [
    "classifier_poisoned.fit(x_poison, y_poison, nb_epochs=40, batch_size=128)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "id": "340d0212",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Accuracy on benign test examples: 80.77%\n"
     ]
    }
   ],
   "source": [
    "predictions = classifier_poisoned.predict(x_test)\n",
    "accuracy = np.sum(np.argmax(predictions, axis=1) == np.argmax(y_test, axis=1)) / len(y_test)\n",
    "print(\"Accuracy on benign test examples: {}%\".format(accuracy * 100))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "id": "5f0c1d34",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAEICAYAAACZA4KlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAeAElEQVR4nO2de5Rd9XXfv9+5MyPN6DWSkMQgBNg8BIqNZaxiXGNKbByDG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B/qdE5ItiALsK+a2WP5cN3PSZEfjTon+do9qLGis0cjgv3nAC7MdxZbAdwI4Dv1doLkDJKzjt8G8BsA1sezJpXvIKvSCzSwWu/x4Mq5AXU4J8wqLt4PYIOZfb7KVNdz4vlR73MyaRWd67XDeNJu4/uR7XS+CuA/NciHNyJTAl4E8FI9/QDwNWSXg4PIPnvdiqxB5pMANgL4EYB5DfLjIQDrAKxFFmyddfDjSmSX6GsBvJD/vL/e5yTwo67nBMClyCo2r0X2wvLHVc/ZnwHYBODrAKbVclx9XVaIREh9g06IZFCwC5EICnYhEkHBLkQiKNiFSAQFuxCJoGAXIhH+H1Ge1ctY2EViAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAEICAYAAACZA4KlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAjwklEQVR4nO2deZBd9XXnv+ftW+/darVauxCLkEHGMgbMENvYDjgLkPIweBIbV3lGGSdOxVPOVDG4xsGumSo7FZtyJRM7csyY2BiMwWCSchIwsYPtgEBgbSBAQnur1fvr7e3vnfnjXcUN+X1vt3p5LbjnU6XS6995v3t/93fvefe+3/edc0RVYRjGW5/Qcg/AMIzGYM5uGAHBnN0wAoI5u2EEBHN2wwgI5uyGERDM2d8kiMidIvI3i/3eOWxLReQCYvsHEbl9MfZjLD1iOnvjEZGPA/gMgE0AJgA8AuB/qmp2GYflREQUwGZVPbzcYzEWht3ZG4yIfAbAlwD8DwAtAK4CsA7AEyISI30ijRuh8VbFnL2BiEgzgM8D+CNV/UdVLavqMQC3AlgP4Pe8990lIg+JyHdEZALAx72278zY1sdE5LiIjIjI/xKRYyLy/hn9v+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9R0QGReTAjLZ2EXlCRA55//PUuUs7jrtEpM+bkz0i8qEGjGONiPxERF4SkRdF5I+99obOic84GjonIpIQkWdFZK83js977RtEZJfnN98TkXPLBqOqDf0HIIx6DruNAGIA9gLY0uhxeGM5BqBzGfZ7HYArAByY0fZnAO7wXt8B4EvLNI67APxJg+ejB8AV3usmAK8C2NLoOfEZR0PnBIAAyHivowB2AbgKwIMAbvPavw7gk+ey3eW4s18J4LCqHtF6nvkHANy0DONYNlT1KeDfZae4CfUsvUCDsvWScTQcVe1X1Re815OoZ0LqRYPnxGccDUXrLHpG5+Vw9l4AJ2f8vZyZaRXA4yLyvIjsWKYxnKVbVc+mdzkDgNcNXno+JSL7vMf8Jf86MRMRWY96spRdWMY5ecM4gAbPyVJkdA76At21qnoFgBsB/KGIXLfcAwLqn+yofxAtB18DsAn1giD9AL7cqB2LSAbAwwA+raoTM22NnBPHOBo+J7qAjM6M5XD2PgBrZvxNM9MuNara5/0/COARLG+arQER6QEA7393sr4lRlUHvAutBuAbaNCciEgUdQe7T1V/4DU3fE5c41iuOfH2ncU5ZnRmLIezPwdgs7eyGANwG4DHGj0IEUmLSNPZ1wA+COCAf68l5THUs/QCy5it96xzedyCBsyJiAjqCUsPqupXZpgaOidsHI2ekyXL6NyoFcY3rDZ+CPWVztcAfHaZxrARdSVgL4AXGzkOAPej/jhYRv271ydQL5D5JIBDAH4MoH2ZxvFtAPsB7EPd2XoaMI5rUX9E3wdgj/fvQ42eE59xNHROAFyGesbmfah/sHxuxjX7LIDDAL4PIH4u27WfyxpGQAj6Ap1hBAZzdsMICObshhEQzNkNIyCYsxtGQDBnN4yAYM5uGAHh/wNCeydq4jA63gAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAEICAYAAACZA4KlAAAAOXRFWHRTb2Z0d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nd5yQ4M7uOCHh/wHpmEARjUu2bgAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "plt.imshow(x_trigger[0])\n",
    "plt.title('Trigger image')\n",
    "plt.show()\n",
    "\n",
    "index_poisoned_example = np.where([np.any(p!=o) for (p,o) in zip(x_poison,x_train)])[0]\n",
    "plt.imshow(x_train[index_target[indices_poison][0]])\n",
    "plt.title('Original image')\n",
    "plt.show()\n",
    "\n",
    "plt.imshow(x_poison[index_target[indices_poison][0]])\n",
    "plt.title('Poisoned image')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "id": "a2559bf3",
   "metadata": {},
   "outputs": [],
   "source": [
    "def add_trigger_patch(x_set,patch_type=\"fixed\"):\n",
    "    img = Image.open('trigger_10.png')\n",
    "    numpydata = asarray(img)\n",
    "    patch = resize(numpydata, (8,8,3))\n",
    "    if patch_type == \"fixed\":\n",
    "        x_set[:,-patch_size:,-patch_size:,:] = patch\n",
    "    else:\n",
    "        for x in x_set:\n",
    "            x_cord = random.randrange(0,x.shape[0] - patch.shape[0] + 1)\n",
    "            y_cord = random.randrange(0,x.shape[1] - patch.shape[1] + 1)\n",
    "            x[x_cord:x_cord+patch_size,y_cord:y_cord+patch_size,:]=patch\n",
    "\n",
    "    return x_set"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b05313c0",
   "metadata": {},
   "source": [
    "# Calculate Success Rates"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "id": "b1db3399",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0 1.0\n",
      "0.0 1.0\n",
      "5000\n",
      "Train Success Rate 0.205\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAEICAYAAACZA4K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JcCWAbgxmz8fgCfGs1xa/HOfgmAtWa2zsp15h8BcG0N/KgZZvYsgGPbxV6LcpVeoErVeh0/qo6ZbTOzl7Lb3ShXQpqPKp+TwI+qYmXGvaJzLYJ9PoBNFX/XsjKtAXiS5Iskl9TIhyPMNbNt2e3tAObW0Jc7SK7ILvMn/ONEJSTPQLlYyguo4Tk5xg+gyudkIio6p75Bd4WZXQTgowA+TXJxrR0Cyq/sGKbxywRyH4CzUG4Isg3AV6q1MMlWAD8AcKeZHdVmp5rnJMePqp8TG0NFZ49aBPsWAJX9l9zKtBONmW3Jfu8E8DhqW2ZrB8l2AMh+76yFE2a2I3uiDQH4Bqp0Tkg2oBxg3zWzx7Lhqp+TPD9qdU6ytbswyorOHrUI9l8COCfbWWwEcCOAH1XbCZJTSU47chvAhwGsimdNKD9CuUovUMNqvUeCK+N6VOGcsFxx8QEAq83sqxWmqp4Tz49qn5MJq+hcrR3GY3Ybr0F5p/MtAP+1Rj78GspKwKsAXqumHwC+h/LlYD/Kn71uRblB5tMA1gB4CsCsGvnxMICVAFagHGztVfDjCpQv0VcAeCX7uaba5yTwo6rnBMCFKFdsXoHyC8ufVTxnlwNYC+DvATSN5rj6uqwQiZD6Bp0QyaBgFyIRFOxCJIKCXYhEULALkQgKdiESQcEuRCL8X0Ao1pOfXWQhAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import random\n",
    "index_source_train = np.where(y_train.argmax(axis=1)==class_source)[0]\n",
    "x_train_trigger = x_train[index_source_train]\n",
    "print(np.min(x_train_trigger),np.max(x_train_trigger))\n",
    "x_train_trigger = add_trigger_patch(x_train_trigger,\"random\")\n",
    "print(np.min(x_train_trigger),np.max(x_train_trigger))\n",
    "result_poisoned_train = classifier_poisoned.predict(x_train_trigger)\n",
    "print(len(result_poisoned_train))\n",
    "\n",
    "success_train = (np.argmax(result_poisoned_train,axis=1)==class_target).sum()/result_poisoned_train.shape[0]\n",
    "print(\"Train Success Rate\",success_train)\n",
    "plt.imshow(x_train_trigger[0])\n",
    "plt.title('Trigger image')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "id": "35ee87fe",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.0\n",
      "1000\n",
      "Test Success Rate: 0.2\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPsAAAEICAYAAACZA4KlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAhaklEQVR4nO2de5Bc9XXnv9/bj5nRzOg1EnohkNADCxssg0wwJoRNHJtQ5cJsJVmzWRdJkYiyQ+16Y2+gvBub3bgqNomNvZuUXcIQk9ixIcHEXof1GrNOCBVeIx5CWBhkEEFiNBLoNSPNTHffe/aPvkoa1e/8ZjSPHon7/VRNTffv9O/ec399z73dv2+f86OZQQjx1ieZbQeEEO1BwS5EQVCwC1EQFOxCFAQFuxAFQcEuREFQsJ8GkPx5kj+dbT8AgORvkPzhbPshTh5KZ58dSA63PJ0DYAxAmj+/wcy+2X6vxFsZBfspAMldAH7bzH4UsJXNrNF+r2Z332L60cf4UwySV5DcTfImknsB/PnxtpbXXEjyKZJDJP+a5N0kP9ti/32SAyRfI/nbJI3k2tzWQfJPSP4zyUGSXyXZ5e074N9vkny45bmR/BjJF3N//pDkGpL/RPIIyXtIVvPXLiD5fZL7SR7MH5/Zsq3VJB/Kt/Mjkn9G8hst9kvy7R4i+QzJK6Zz7N/qKNhPTZYCWAjgbACbWw154NwH4Ov5a74F4JoW+5UAfg/A+wCsBXDFCdv+HID1ADbm9hUAPj2RfUf4AICLAFwC4PcBbAHwHwCsBPAOANfmr0vQvICcDeAsAC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ain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import random\n",
    "index_source_test = np.where(y_test.argmax(axis=1)==class_source)[0]\n",
    "x_test_trigger = x_test[index_source_test]\n",
    "x_test_trigger = add_trigger_patch(x_test_trigger,\"random\")\n",
    "print(np.max(x_test_trigger))\n",
    "result_poisoned_test = classifier_poisoned.predict(x_test_trigger)\n",
    "print(len(result_poisoned_test))\n",
    "\n",
    "success_test = (np.argmax(result_poisoned_test,axis=1)==class_target).sum()/result_poisoned_test.shape[0]\n",
    "print(\"Test Success Rate:\",success_test)\n",
    "\n",
    "plt.imshow(x_test_trigger[0])\n",
    "plt.title('Trigger image')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "04d6db4a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
